package Demo4;

public class News implements Comparable{
    private int nid;
    private String title;
    private String content;
    private int click;

    public News(){

    }

    public News(int nid, String title, String content, int click) {
        this.nid = nid;
        this.title = title;
        this.content = content;
        this.click = click;
    }

    public int getNid() {
        return nid;
    }

    public void setNid(int nid) {
        this.nid = nid;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public int getClick() {
        return click;
    }

    public void setClick(int click) {
        this.click = click;
    }

    public int compareTo(Object object) {
        int N=getClick()-getClick();
        return N;
    }

    public int compareTo(Object object1, Object object2) {
        News news1=(News) object1;
        News news2=(News) object2;
        int N=news1.getNid()-news2.getNid();
        if (N>0){
            return 1;
        }else if (N==0){
            return 0;
        }else if (N<0){
            return -1;
        }
        return  0;
    }
}
